<template>
  <div class="permission-container">
    <div class="permission-header">
      <el-button type="primary" @click="handleCreateUser">创建用户</el-button>
      <el-input
        v-model="searchQuery"
        placeholder="搜索用户名"
        style="width: 200px"
        clearable
      />
    </div>

    <el-table
      :data="userList"
      style="width: 100%"
      border
    >
      <el-table-column prop="username" label="用户名" />
      <el-table-column prop="role" label="角色" />
      <el-table-column prop="createTime" label="创建时间" />
      <el-table-column prop="lastLoginTime" label="最后登录时间" />
      <el-table-column label="操作" width="200">
        <template #default="{ row }">
          <el-button
            type="primary"
            link
            @click="handleEditUser(row)"
          >编辑</el-button>
          <el-button
            type="danger"
            link
            @click="handleDeleteUser(row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      v-model:current-page="currentPage"
      v-model:page-size="pageSize"
      :total="total"
      :page-sizes="[10, 20, 50, 100]"
      layout="total, sizes, prev, pager, next"
      class="pagination"
    />
  </div>
</template>

<script setup>
import { ref } from 'vue'

const searchQuery = ref('')
const currentPage = ref(1)
const pageSize = ref(10)
const total = ref(0)
const userList = ref([])

const handleCreateUser = () => {
  // TODO: 实现创建用户逻辑
}

const handleEditUser = (row) => {
  // TODO: 实现编辑用户逻辑
}

const handleDeleteUser = (row) => {
  // TODO: 实现删除用户逻辑
}
</script>

<style scoped>
.permission-container {
  padding: 20px;
}

.permission-header {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
}

.pagination {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}
</style>